/*******************************************************************\
| Triangle.h
|
| CREATED:		13.6.2009
| DESCRIPTION:
| 
| Triangle scene object class
\********************************************************************/
#ifndef TRIANGLE_H
#define TRIANGLE_H

#include "Object.h"

namespace PhotonMapping
{

//*****************************************************************************
// class overview:
//  2D triangle object implementation 
//-----------------------------------------------------------------------------
class Triangle : public IObject
{
	public:
		// constructor, triangle points in clock-wise order
		Triangle(const Math::Vector3& p_P0, const Math::Vector3& p_P1, const Math::Vector3& p_P2, intx p_MaterialId);

		// test for ray/triangle intersection
		virtual intx TestIntersection(const Math::Ray& p_Ray, float &p_Distance);

		// return bounding sphere
		virtual const Math::Sphere& GetBoundingSphere() const;

		// return the surface normal for the given point
		virtual const Math::Vector3 GetNormalAt(const Math::Vector3& p_Pos);

	private:
		// triangle points
		Math::Vector3 m_P0, m_P1, m_P2;

		// plane normal
		Math::Vector3 m_Normal;

		// object bounding sphere
		Math::Sphere m_BoundingSphere;
};


}

#endif // TRIANGLE_H
